<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>登录</title>
    
    <meta name="content-type" content="text/html; charset=UTF-8">
    <?xml encoding="UTF-8"?>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<link rel="stylesheet" type="text/css" href="css/logintest.css">


    <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" >
    
      function validateForm(){
          let uname = document.forms["login"]["uaccount"].value;
          let upwd = document.forms["login"]["upwd"].value;
          let code = document.forms["login"]["checkcode"].value;
          if (uname ==null || uname ==="")
		  {
		    alert("姓名必须填写！");
		    return false;
		  }else if (upwd ==null || upwd ==="")
		  {
		    alert("密码不能为空！");
		    return false;
		  }else if (code ==null || code ===""){
		    alert("必须输入验证码！");
		    return false;
		  }		  
	  }

      function reloadCheckImg()
      {
          $("img").attr("src","img.jsp?t="+(new Data().getTime()));
      }

      $(document).ready(function()
      {
          $("checkcodeId").blur(function()
          {
              var $checkcode = $("#checkcodeId").val();
              $.post(
                  "LoginServlet",
                  "checcode="+$checkcode,
                  function(result)
                  {
                      var result = $("<img src = '"+result+"' height='15' width='15px' />");
                  });
          });
      });

    </script>


    
  </head>
  
 <body>
 <div class="segment">
     <h1>登录</h1>
 </div>
  <center>
  <form name="login"  action="loginServlet" onsubmit="return validateForm()" method = "get">

      <label class="label1">
          <input  type = "text" name = "uaccount" placeholder="身份证号/上班工号" class="input1">
      </label>
      <label class="label1">
          <input  type = "password" name = "upwd" placeholder="密码" class="input1">
      </label>
      <label class="label1">
          <select class="input1" name="loginType">
              <option value="none">请选择用户类型</option>
              <option value ="patient">病人</option>
              <option value ="doctor">医生</option>
              <option value="2">药物处</option>
              <option value="3">住院部</option>
          </select>
      </label>
      <label class="label1">
          <input type="text" name="checkcode" id= "checkcode" size="4" placeholder="验证码" class="input1">
      </label>
      <a href="javascript:reloadCheckImg();"><img src="img.jsp"/></a>&nbsp;&nbsp;&nbsp;&nbsp;（看不清换下一张）
      <br>
      <input  type = "submit" value = "登录"  class="sub">&nbsp;&nbsp;&nbsp;&nbsp;
      <a href="enroll.jsp"><input type="button" value="注册"  class="sub"></a>

  </form>
  </center>



 </body>
  

</html>
